#ifndef EVILQQ_H
#define EVILQQ_H

#include <unistd.h>
#include <stdlib.h>
#include <getopt.h>
#include <signal.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <time.h>
#include <sys/time.h>
#include <termio.h>

#include "list.h"

#define DEBUGGING 0
#define VERSION 0x2227

#define MAX_BUDDY 1200
#define MAX_QUN 128
#define MAX_QUN_MEMBER 800
#define MAX_GROUP 128


typedef enum {
    TCP, UDP, PROXY
} connecttype;

typedef enum {
    QQ_NONE = 0x00,
    QQ_ONLINE = 0x0a,
    QQ_OFFLINE = 0x14,
    QQ_AWAY = 0x1e,
    QQ_BUSY = 0x32,
    QQ_KILLME = 0x3c,
    QQ_QUIET = 0x46,
    QQ_HIDDEN = 0x28
} status;

typedef enum {
    P_INIT = 0,
    P_LOGGING,
    P_VERIFYING,
    P_LOGIN,
    P_ERROR,
    P_DENIED,
    P_WRONGPASS,
    P_BUSY,
    P_WAITING
} login_process;

typedef struct server {
    struct in_addr host;
    unsigned short portno;
    struct server *next;
} server;


struct ops {
    int debugging;
    int color;
    int log;
    connecttype contype;
    server *tcpserver;
    server *udpserver;
    server *proxyserver;
};

typedef struct qqinfo{
    unsigned int id;
    unsigned short version;
    unsigned short seqno;
    int socket;
    char encrypted_password[16];
    char encrypted_password_v2011[16];
    status st;
    login_process process;
    list buddy_list;
    list qun_list;
    list group_list;
    
} qqinfo;

typedef struct qqbuddy{
    unsigned int id;
//    char nickname[NICKNAME_LEN];
    struct in_addr ip;
    unsigned short portno;
    unsigned short face;
    unsigned char age;
    unsigned char sex;
    unsigned char gid;
    unsigned char qqshow;
    unsigned char flag;
} qqbuddy;


int my_getpass(const char *fmt, ...); 
void my_crypt(const char *pass, char *encrypted, int passlen);
void sigdie(int signo);
void options_init();
void printusage(char *name);
int getserverlist(char *s, server *slist);
static void clear_screen();
void qqinfo_create(qqinfo *qq, unsigned int qqid, char *password);

#endif /* EVILQQ_H */

